package com.dingding.activity.core.activity.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.activity.core.activity.dao.IActivityDao;
import com.dingding.common.core.base.daox.ICriteriaBaseDao;
import com.dingding.common.core.beans.Activity;

/**
 * 
 * @Description: 活动表DAO
 * @author CHEHUANBO
 * @date 2016年12月6日
 * @since V2.6.2
 * 
 */
@Component("_activityDao")
public class ActivityDaoImpl implements IActivityDao {

	private static final Logger log = Logger.getLogger(ActivityDaoImpl.class);



	@Resource(name = "criteriaBaseDao")
	private ICriteriaBaseDao criteriaDao;


	/**
	 * 
	 * @Description: 从数据库获取所有有效活动
	 * @return List<Activity> 查询到的所有有效活动
	 * @author CHEHUANBO
	 * 
	 */
	@Override
	@Transactional(readOnly = true)
	public List<Activity> getAllActivityToDb() {

		Criterion criterion = Restrictions.eq("snSatatus", 1);
		try {

			List<Activity> activitieList = criteriaDao.queryCriteriaList(Activity.class, criterion);

			return activitieList;

		} catch (Exception e) {
			log.error("从数据库中获取所有有效活动出现异常！", e);
		}

		return null;
	}

}
